let john = {name: "John", age: 25};
let pete = {name: "Pete", age: 30};
let mary = {name: "Mary", age: 29};

let arr = [john, pete, mary];

alert(getAverageAge(arr));


function getAverageAge(arr) {
    let sum = arr.reduce((sum, current) => sum + current.age, 0);
    return sum / arr.length;
}